package com.itheima.springboottlias.exception;

import com.itheima.springboottlias.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler extends RuntimeException{

    @ExceptionHandler(Exception.class)
    public Result exception(Exception e){
        log.info(e.getMessage() , e);
        return Result.error("未知异常");
    }
    @ExceptionHandler(RuntimeException.class)
        public Result exception(RuntimeException e){
        log.info(e.getMessage(),e);
        return Result.error(e.getMessage());

        }

}
